﻿package mortal.game.view.daily.render
{
    import Message.DB.Tables.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.daily.*;

    public class DailyVitalityCellRenderer extends GCellRenderer
    {
        private var _selectFilter:ScaleBitmap;
        private var _icon:GImageBitmap;
        private var _name:GTextFiled;
        private var _dec:GTextFiled;
        private var _vitality:GTextFiled;
        private var _oper:GTextFiled;

        public function DailyVitalityCellRenderer()
        {
            return;
        }// end function

        private function onClickOper(event:TextEvent) : void
        {
            DailyUtil.oper(this.itemData);
            return;
        }// end function

        private function get itemData() : TDailyViewConfig
        {
            return _data as TDailyViewConfig;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            var _loc_2:* = Cache.instance.daily;
            var _loc_3:* = int(_loc_2.data.times[this.itemData.type]) >= int(this.itemData.activityValue) ? (int(this.itemData.activityValue)) : (int(_loc_2.data.times[this.itemData.type]));
            var _loc_4:* = "(" + _loc_3 + "/" + this.itemData.activityValue + ")";
            this._icon.imgUrl = this.itemData.icon + ".jpg";
            this._name.text = this.itemData.name;
            this._name.toolTipData = Language.getStringByParam(70628, this.itemData.name, this.itemData.minLevel);
            this._dec.htmlText = this.itemData.activityDesc + HTMLUtil.addColor(_loc_4, GlobalStyle.colorLv);
            this._vitality.text = Language.getStringByParam(70406, this.itemData.personActivity);
            if (int(this.itemData.times) > 0 && int(_loc_2.data.times[this.itemData.type]) >= int(this.itemData.activityValue))
            {
                this._oper.htmlText = HTMLUtil.addColor("" + Language.getString(71034), GlobalStyle.colorLv);
            }
            else
            {
                this._oper.htmlText = HTMLUtil.addLink("" + Language.getString(71035), GlobalStyle.colorLv);
            }
            this.filters = DailyUtil.isComplete(this.itemData) ? ([FilterConst.colorFilter2]) : (null);
            return;
        }// end function

        override public function set selected(param1:Boolean) : void
        {
            super.selected = param1;
            this._selectFilter.visible = param1;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._selectFilter = UIFactory.bg(-1, -1, 398, 38, this, ImagesConst.selectFilter);
            pushUIToDisposeVec(UIFactory.bg(0, 35, 405, 2, this, ImagesConst.SplitLine));
            var _loc_1:* = UIFactory.bg(7, 4, 70, 70, this, ImagesConst.ShopItemBg);
            var _loc_2:Number = 0.4;
            _loc_1.scaleY = 0.4;
            _loc_1.scaleX = _loc_2;
            pushUIToDisposeVec(_loc_1);
            this._icon = UIFactory.gImageBitmap("", 10, 6, this);
            var _loc_2:Number = 0.39;
            this._icon.scaleY = 0.39;
            this._icon.scaleX = _loc_2;
            this._name = UIFactory.gTextField("", 52, 9, 180, 20, this);
            this._dec = UIFactory.gTextField("", 140, 9, 170, 20, this);
            this._vitality = UIFactory.gTextField("", 295, 9, 50, 20, this);
            this._oper = UIFactory.gTextField("", 365, 9, 30, 20, this);
            this._oper.configEventListener(TextEvent.LINK, this.onClickOper);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._selectFilter.dispose(param1);
            this._icon.dispose(param1);
            this._name.dispose(param1);
            this._dec.dispose(param1);
            this._vitality.dispose(param1);
            this._oper.dispose(param1);
            this._selectFilter = null;
            this._icon = null;
            this._name = null;
            this._dec = null;
            this._vitality = null;
            this._oper = null;
            return;
        }// end function

    }
}
